﻿@using WebShop.Contracts
@using WebShop.Infrastructure;
@using Webdiyer.WebControls.Mvc;
@using WebShop.ViewModels;

@model WebShop.Contracts.ProductsReport

@{
    ViewBag.Title = "Index";
}

@section scripts
{
    <script src="@Url.Script("jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Script("jquery.validate.unobtrusive.js")" type="text/javascript"></script>
}

<h2>Index</h2>

@using (Html.BeginForm())
{
    <label>from:</label>
    @Html.EditorFor(model => model.StartDate)
    <label>to:</label>
    @Html.EditorFor(model => model.EndDate)

    <input type="submit" value="Filter" />
}

<table>
    <tr>
        <th>
            ProductName
        </th>
        <th>
            ProductCategory
        </th>
        <th>
            Amount
        </th>
        <th>
            Sum
        </th>
        <th></th>
    </tr>

@foreach (var item in Model.Products)
{
    <tr>
        <td>
            @Html.ActionLink(item.ProductName, "Details", "Products", new { id = item.ProductID }, new { title = "View products details for: " + item.ProductName })
        </td>
         <td>
            @Html.ActionLink(item.CategoryName, "Index", "Products", new { categoryID = item.CategoryID }, new { title = "View products in category" })
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Amount)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Sum)
        </td>
    </tr>
}

</table>

<p>
    @Html.Pager((PagedList<ProductReport>)Model.Products, new PagerOptions() { PageIndexParameterName = "pageIndex", ShowDisabledPagerItems = false, AlwaysShowFirstLastPageNumber = true }, new { StartDate = Model.StartDate, EndDate = Model.EndDate })
</p>